import sys
from PySide6.QtWidgets import QApplication, QWidget, QMenuBar, QMenu
from PySide6.QtCore import QDate
from PySide6.QtGui import QAction


class MenuDemo(QWidget):
    def __init__(self):
        super().__init__()
        self.resize(800, 600)
        self.setWindowTitle('菜单栏')
        men_bar = QMenuBar(self)

        file_menu = QMenu("文件123", self)
        edit_menu = QMenu("编辑123", self)
        see_menu = QMenu("查看123", self)
        

        # 给菜单添加动作
        new_act = QAction("新建文件", self)
        openAct = QAction('打开文件', self)
        saveAct = QAction('保存文件', self)
        file_menu.addActions([new_act, openAct, saveAct])

        # 编辑的操作
        copyAct = QAction("复制",self)
        cutAct = QAction('剪切', self)
        pasteAct = QAction('粘贴', self)
        edit_menu.addActions([copyAct, cutAct, pasteAct])


        # 查看的子菜单栏
        sub_menu = QMenu("外观", self)
        ap = QAction("全屏", self)
        center = QAction("居中", self)
        sub_menu.addActions([ap, center])
        # 把外观的菜单栏放入查看的菜单栏下
        see_menu.addMenu(sub_menu)

        men_bar.addMenu(file_menu)
        men_bar.addMenu(edit_menu)
        # 把查看的菜单栏放入到menbar中
        men_bar.addMenu(see_menu)



if __name__ == "__main__":
    app = QApplication(sys.argv)
    window = MenuDemo()
    window.show()
    sys.exit(app.exec())
